<!DOCTYPE html>
<html>
<head>
    <title>网站信息管理</title>
    <include file='public/head'>
	<style>
		.layui-legend-size{font-size:14px !important;}
		.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
	</style>
</head>
<body>
	<!-- layui-tab开始 -->
	<div class="layui-tab " lay-filter="demo-tab" >
        <div class="layui-col-md12">
            
            <div class="layui-col-md8 layui-col-md-offset2" >
                <blockquote class="layui-elem-quote" style="margin-top:10px;">温馨提示: 网站基础配置请谨慎修改</blockquote>
                <!-- 开始 -->
                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站Logo</label>
                                <div class="layui-input-block">
                                    <php>
                                        $imgs = '';
                                        if( !empty( $config ['logo'] ) ) {
                                            $imgs = zy_domain().$config ['logo'] ; 
                                        } 
                                    </php>
                                    <img id="img_logo" src="{$imgs}" alt="logo" style="width:80px;height:80px;border:1px solid #ccc;" /> 点击图片上传logo
                                    <input type="hidden" id="logo_icon" name="logo" required  lay-verify="" placeholder="" autocomplete="off" class="layui-input" value="{$config.logo|default=''}" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站域名</label>
                                <div class="layui-input-block">
                                    <input type="name" name="domain_name" required  lay-verify="domain_name" placeholder="请输入网站域名 https://xxx.cn" autocomplete="off" class="layui-input" value="{$config.domain_name|default=''}" >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">公司名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="company_name" required  lay-verify="" placeholder="请输入公司名称 xxx公司" autocomplete="off" class="layui-input" value="{$config.company_name|default=''}" >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站标题</label>
                                <div class="layui-input-block">
                                    <input type="text" name="title" required  lay-verify="" placeholder="请输入网站标题 xx商城" autocomplete="off" class="layui-input" value="{$config.title|default=''}" >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">关键字</label>
                                <div class="layui-input-block">
                                    <input type="text" name="keywords" required  lay-verify="" placeholder="请输入关键字" autocomplete="off" class="layui-input" value="{$config.keywords|default=''}" >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">站点名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="site_name" required  lay-verify="" placeholder="请输入站点名" autocomplete="off" class="layui-input" value="{$config.site_name|default=''}" >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站备案号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="icp" required  lay-verify="" placeholder="请输入网站备案号" autocomplete="off" class="layui-input" value="{$config.icp|default=''}" >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">平台客服联系方式</label>
                                <div class="layui-input-block">
                                    <input type="text" name="contact_way" required  lay-verify="" placeholder="请输入平台客服联系方式 xxxx-xxxxxxx,1xxxxxxxxxx,xxx@xx.com" autocomplete="off" class="layui-input" value="{$config.contact_way|default=''}" >
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">描述</label>
                                <div class="layui-input-block">
                                    <textarea name="desc" placeholder="请输入描述" class="layui-textarea">{$config.desc|default=''}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="sitesave">保存设置</button>
                                </div>
                            </div>
                        </form>
            </div>
        </div>
		
		
		
	</div>
	<!-- layui-tab结束-->
	<include file='public/scripts'>
    
	<script>
	    ;(function(){
	        var form = layui.form;
	        var upload = layui.upload; 
        
            var domain = '{:zy_domain()}';
            //执行实例
            var uploadInst = upload.render({
                elem: '#img_logo' //绑定元素
                ,url: '{:cmf_plugin_url("SiteConfig://admin_index/logoIcon")}' //上传接口
                ,done: function(res){
                //上传完毕回调
                    layer.msg( res.message , { time:1000 , icon:(res.code ==200 )?1:5 } , function(){
                        if ( res.code == 200 ){
                            $( '#img_logo' ).attr( 'src' , domain+res.data );
                            $( '#logo_icon' ).val( res.data );
                        }
                    } );
                }
                ,error: function(){
                //请求异常回调
                }
            });
	        //监听提交
            form.on('submit(sitesave)', function(data){
                //询问框
                layer.confirm('站点配置信息,请谨慎修改,确定要修改吗？', 
                    {
                        btn: ['确定','取消'], //按钮
                        title:"修改提示",
                        icon: 3
                    },
                    function(){
                        $.post( '{:cmf_plugin_url("Setting://setting/saveSetting")}' , { name : 'site_config' , data : data.field } , function( res ){
                            	layer.msg( res.message , { time: 800 } , function(){
                            } );
                        } );
                    },
                    function(){
                        layer.msg('操作取消');
                        window.location.reload();
                    }
                );
                
                return false;
            });
            
            form.verify({
              domain_name: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp(/(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?/).test(value)){
                  return '请输入正确的域名';
                }
              }

            }); 
            
	    })();
	</script>
	



</body>
</html>